import request from '@/utils/axios/index'
import type { Dayjs } from 'dayjs'

/** 合同档案-支出信息 */
export interface ContractArchiveExpense {
  id: number // id
  contractArchiveId: number // 合同档案id
  name: string // 名称
  type: string // 类型
  isPaid: string // 是否完成支付
  money: number // 金额
  receiver: string // 收款方
  content: string // 内容
  contentDate: string | Dayjs // 日期
  confirmPerson: string // 支付确认人
  confirmDate: string | Dayjs // 支付确认时间
  remark: string // 备注
}

// 合同档案-支出 API
export const ContractArchiveExpenseApi = {
  // 查询合同档案-支出分页
  getContractArchiveExpensePage: async (params: any) => {
    return await request.get({ url: `/san/biz-contract-archive-expense/page`, params })
  },

  // 查询合同档案-支出详情
  getContractArchiveExpense: async (id: number) => {
    return await request.get({ url: `/san/biz-contract-archive-expense/get?id=` + id })
  },

  // 新增合同档案-支出
  createContractArchiveExpense: async (data: ContractArchiveExpense) => {
    return await request.post({ url: `/san/biz-contract-archive-expense/create`, data })
  },

  // 修改合同档案-支出
  updateContractArchiveExpense: async (data: ContractArchiveExpense) => {
    return await request.put({ url: `/san/biz-contract-archive-expense/update`, data })
  },

  // 删除合同档案-支出
  deleteContractArchiveExpense: async (id: number) => {
    return await request.delete({ url: `/san/biz-contract-archive-expense/delete?id=` + id })
  },

  /** 批量删除合同档案-支出 */
  deleteContractArchiveExpenseList: async (ids: number[]) => {
    return await request.delete({
      url: `/san/biz-contract-archive-expense/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出合同档案-支出 Excel
  exportContractArchiveExpense: async (params) => {
    return await request.download({ url: `/san/biz-contract-archive-expense/export-excel`, params })
  }
}
